//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "adminActions\fn_playerMonitor.sqf"
#include <core_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

diag_log format ["MSO-%1 FNC_PLAYERMONITOR: started",time];

if (GVAR(AdminCmds) == 1) then { 
	private ["_end","_isAdmin","_isModerator","_isTeamMember","_isDeveloper","_action_id"];
	teleportMode = false;
	_end = false;
	player addeventhandler ["Respawn",{GVAR(MarkerAction) = -1;GVAR(TeleportAction) = -1;GVAR(GhostAction) = -1; GVAR(ModerationAction) = -1;} ];
	while { true } do { 
		waituntil { (!isnull player && {alive player}) };
		_isAdmin = serverCommandAvailable "#kick" || !isMultiplayer;
		_isDeveloper = _isAdmin;
		_isModerator = _isDeveloper;
		_isTeamMember = _isModerator;
		if (!isnil "mp_rights_fnc_isAdmin") then {
			_isAdmin = _isAdmin || ([] call mp_rights_fnc_isAdmin);
			_isDeveloper = _isDeveloper || _isAdmin || ([] call mp_rights_fnc_isDeveloper);
			_isModerator = _isModerator || _isDeveloper || _isAdmin || ([] call mp_rights_fnc_isModerator);
			_isTeamMember = _isTeamMember || _isModerator || _isAdmin || ([] call mp_rights_fnc_isMember);
		};
		
		if (isNil "TYR_MENU_IsActive" || {TYR_MENU_IsActive <= 0}) then {
			// Managing admin commands
			if (GVAR(AdminCmdGhost) == 1) then { [_isDeveloper] call FUNC(ghostModeAction); };
			if (GVAR(AdminCmdTeleport) == 1) then {	[_isDeveloper] call FUNC(teleportModeAction); };
			
			// Managing Moderator commands
			if (GVAR(AdminModeration) == 1) then { [_isTeamMember] call FUNC(moderationAction); };
			
			// Managing Member commands
			if (GVAR(AdminCmdMarker) == 1) then { [_isTeamMember] call FUNC(markerModeAction); };
		};
		sleep 3;
	};
};

	
TRACE("End");
TMFPROFILERSTOP;
